package com.example.wanted.repository;

import com.example.wanted.model.Comment;
import com.example.wanted.model.Question;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;


@Repository
@Qualifier("comment")
public interface CommentRepository extends JpaRepository<Comment,Long> {
    @Query("select u from comment u where u.user_id = ?1")
    public Comment[] findByUser(String user_id);

    @Query("select u from comment u where u.question_id = ?1")
    public Comment[] findByQuestion(Long question_id);

    @Query("select u.user_id from comment u where u.question_id = ?1")
    public Long findQuestionByUser(String user_id);

    @Query("select u.question_id from comment u where u.user_id = ?1")
    public String findUserByQuestion(Long question_id);
}
